<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="ftime"></div>
<button id="ftimebutton">停止</button>
<script>
var ftime = document.getElementById('ftime');
var ftimeId;
var ftimebutton= document.getElementById('ftimebutton');

ftimebutton.onclick=function () {timeStop();};
getime();

window.onload = function () {
    timeMove();
}
function getime() {
    var date = new Date();
    return  setime(date.getHours(),date.getMinutes(),date.getSeconds());
}
function setime(h,m,s) {
    ftime.innerHTML=h+":"+m+":"+s;
}
function timeMove() {
     ftimeId = setInterval(getime,1000);
}
function timeStop() {
    clearInterval(ftimeId);
}
</script>

</body>
</html>